package svc

import (
	"github.com/zeromicro/go-zero/core/stores/sqlx"
	"order_rpc/internal/config"
	"order_rpc/models"
)

type ServiceContext struct {
	Config          config.Config
	Conn            sqlx.SqlConn
	OrderModel      models.OrdersModel
	OrderGoodsModel models.OrderGoodsModel
}

func NewServiceContext(c config.Config) *ServiceContext {
	conn := sqlx.NewMysql(c.Mysql.DataSource)
	return &ServiceContext{
		Config:          c,
		Conn:            conn,
		OrderModel:      models.NewOrdersModel(conn, c.Cache),
		OrderGoodsModel: models.NewOrderGoodsModel(conn, c.Cache),
	}
}
